<?php
/**
 * Created by PhpStorm.
 * User: a4041
 * Date: 2018/6/13
 * Time: 13:46
 */

namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
    protected $hidden = ['password', 'remember_token','payword'];
    protected $fillable = ['avatar','name','mobile','sex'];

    /**
     * 获取关联到用户详细信息
     */
    public function userInfo()
    {
        return $this->hasOne('App\Models\UserInfo')->select('user_id','id_card','real_name');
    }
    /**
     * 获取关联到用户详细信息,后台系统专用
     */
    public function userInfoSys()
    {
        return $this->hasOne('App\Models\UserInfo');
    }
    /**
     * 获取关联的用户店铺
     */
    public function Myshop()
    {
        return $this->hasOne('App\Models\Shop');
    }

    /**
     * 获取关联到用户地址信息
     */
    public function Addresses()
    {
        return $this->hasMany('App\Models\Comment');
    }

    /**
     * 获取关联到用户默认地址
     */
    public function defaultAddresses()
    {
        return $this->hasOne('App\Models\Address','user_id','id')->where('pretermission',1);
    }

    /**
     * 获取关联到商家申请审核表
     */
    public function shopApply()
    {
        return $this->hasOne('App\Models\ShopApply');
    }

    /**
     * 获取关联到银行卡
     */
    public function cashconfig()
    {
        return $this->hasMany('App\Models\CashConfig','user_id','id');
    }

}